<template>
  <div>
    <el-row style="padding:20px;margin-top:20px">
      <el-col :span="18">
        <el-form :model="form" :rules="rules" ref="form" label-width="200px" label-suffix="：">
          <el-row>
            <el-col :span="12">
              <el-form-item label="组织名称" prop="societyOrgName">
                <el-input v-model="form.societyOrgName"></el-input>
              </el-form-item>
              <el-form-item label="登记证号" prop="registerNumber">
                <el-input v-model="form.registerNumber"></el-input>
              </el-form-item>
              <el-form-item label="登记管理机关代码" prop="registerManagOrgCode">
                <el-input v-model="form.registerManagOrgCode"></el-input>
              </el-form-item>
              <el-form-item label="法定代表人姓名">
                <el-input v-model="form.headerName"></el-input>
              </el-form-item>
              <el-form-item label="批准日期">
                <el-date-picker @change="changeDate" v-model="form.approvalDate"></el-date-picker>
              </el-form-item>
              <el-form-item label="状态">
                <el-radio-group v-model="form.status">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="负责人证件号码">
                <el-input v-model="form.responsiblePersonCertifID"></el-input>
              </el-form-item>
              <el-form-item label="负责人联系方式">
                <el-input v-model="form.responsiblePersonContact"></el-input>
              </el-form-item>
              <el-form-item label="治保负责人姓名">
                <el-input v-model="form.securityLeaderName"></el-input>
              </el-form-item>
              <el-form-item label="保卫负责人身份证">
                <el-input v-model="form.securityLeaderCertID"></el-input>
              </el-form-item>
              <el-form-item label="行政区划代码">
                <v-distpicker @selected="getValue" :province="Area.province.Name" :city="Area.city.Name" :area="Area.area.Name"></v-distpicker>
              </el-form-item>
              <el-form-item label="关注程度">
                <el-select v-model="form.attentionTypeValue">
                  <el-option v-for="v in AttentionType" :key="v.id" :value="v.attentionTypeValue" :label="v.attentionTypeName"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item v-if="form.isCanConstructCPC==1" label="是否有中共党组织">
                <el-radio-group v-model="form.hasCPC">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="中共党员数量" v-if="form.hasCPC==1">
                <el-input-number :min="0" v-model="form.numberofCPCMember"></el-input-number>
              </el-form-item>
              <el-form-item label="是否有工会">
                <el-radio-group v-model="form.hasLabourUnion">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="工会成员数量" v-if="form.hasLabourUnion==1">
                <el-input-number :min="0" v-model="form.numberofLUMember"></el-input-number>
              </el-form-item>
              <el-form-item label="是否有妇联">
                <el-radio-group v-model="form.hasWomenFederation">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="妇女数量" v-if="form.hasWomenFederation">
                <el-input-number :min="0" v-model="form.numberofWomen"></el-input-number>
              </el-form-item>
              <el-form-item label="资金来源">
                <el-input v-model="form.sourceofFunds"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="统一社会信用代码">
                <el-input disabled v-model="form.enterpriseUSCcode"></el-input>
              </el-form-item>
              <el-form-item label="成立日期" prop="establishDate">
                <el-date-picker v-model="form.establishDate"></el-date-picker>
              </el-form-item>
              <el-form-item label="创建日期" prop="creationDate">
                <el-date-picker v-model="form.creationDate"></el-date-picker>
              </el-form-item>
              <el-form-item label="所属网格">
                <el-select v-model="form.netGridID">
                  <el-option v-for="v of GridID" :key="v.id" :value="v.netGridID" :label="v.netGridName"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="住所">
                <el-input v-model="form.livingHouse"></el-input>
              </el-form-item>
              <el-form-item label="社会组织类型">
                <el-select v-model="form.societyOrgTypeValue">
                  <el-option v-for="v in SocietyOrgType" :key="v.id" :value="v.societyOrgTypeValue" :label="v.societyOrgTypeName"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="负责人证件代码">
                <el-select v-model="form.responsiblePersonCertTypeValue">
                  <el-option v-for="v in personType" :key="v.id" :label="v.enterpriseLeaderCertTypeName" :value="v.enterpriseLeaderCertTypeValue"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="负责人姓名">
                <el-input v-model="form.responsiblePersonName"></el-input>
              </el-form-item>
              <el-form-item label="办公地址">
                <el-input v-model="form.officeAddress"></el-input>
              </el-form-item>
              <el-form-item label="治保负责人联系方式">
                <el-input v-model="form.securityLeaderContact"></el-input>
              </el-form-item>
              <el-form-item label="否具备建立中共党组织条件">
                <el-radio-group v-model="form.isCanConstructCPC">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否有共青团">
                <el-radio-group v-model="form.hasCYL">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="共青团员数量" v-if="form.hasCYL">
                <el-input-number :min="0" v-model="form.numberofLCYLMember"></el-input-number>
              </el-form-item>
              <el-form-item label="是否有境外背景">
                <el-radio-group v-model="form.isOverseasBackground">
                  <el-radio-button :label="1">是</el-radio-button>
                  <el-radio-button :label="0">否</el-radio-button>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20" align="center">
              <el-form-item>
                <el-button type="warning" @click="resetForm('form')">重置</el-button>
                <el-button type="primary" @click="saveForm('form')">更新</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
    </el-row>


  </div>
</template>

<script>
import * as api from "@/api/orgManage";
import VDistpicker from "v-distpicker";
import pca from "@/utils/pca";

export default {
  components: {
    VDistpicker,

  },
  data() {
    return {
      Area: {
        province: { AreaCode: "", Name: "" },
        city: { AreaCode: "", Name: "" },
        area: { AreaCode: "", Name: "" }
      },
      form: {
        enterpriseUSCcode: "", //'统一社会信用代码',
        establishDate: "", // date DEFAULT NULL COMMENT '成立日期',
        creationDate: "", //date DEFAULT NULL COMMENT '创建日期',
        registerNumber: "", //'登记证号',
        societyOrgName: "", //组织名称,
        netGridID: "",
        registerManagOrgCode: "", //'登记管理机关代码',
        headerName: "", //'法定代表人姓名',
        livingHouse: "", //'住所',
        approvalDate: "", //'批准日期，YYYYMMDD',
        societyOrgTypeValue: "", //'编码见5.47',
        status: "", //
        responsiblePersonCertTypeValue: "", //'负责人证件代码，编码符合GA/T 517',
        responsiblePersonCertifID: "", //'负责人证件代码',
        responsiblePersonName: "", //'负责人姓名',
        responsiblePersonContact: "", //'负责人联系方式',
        officeAddress: "", //,
        regionalismCode: "", // varchar(6) DEFAULT NULL COMMENT '行政区划代码',
        securityLeaderCertID: "", // varchar(18) DEFAULT NULL COMMENT '保卫负责人身份证号码',
        securityLeaderName: "", //'治保负责人姓名',
        securityLeaderContact: "", //'治保负责人联系方式',
        attentionTypeValue: "", //'关注程度，编码见5.46',
        isCanConstructCPC: "", //'是否具备建立中共党组织条件？',
        hasCPC: "", //'是否有中共党组织？',
        numberofCPCMember: "", //'中共党员数量',
        hasLabourUnion: "", //'是否有工会？',
        numberofLUMember: "", //'工会成员数量',
        hasCYL: "", //'是否有共青团？',
        numberofLCYLMember: "", //'共青团员数量',
        hasWomenFederation: "", //'是否有妇联？',
        numberofWomen: "", //'妇女数量',
        sourceofFunds: "", //'资金来源',
        isOverseasBackground: "", //'是否有境外背景？',
        longitude: "", //'地理经度信息',
        latitude: "" //'地理纬度信息'
      },
      rules: {
        societyOrgName: [
          {
            required: true,
            message: "请输入组织名称",
            trigger: "blur"
          }
        ],
        registerNumber: [
          {
            required: true,
            message: "请输入组织登记证号",
            trigger: "blur"
          }
        ]
      },
      GridID: [],
      SocietyOrgType: [],
      personType: [],
      AttentionType: []
    };
  },
  methods: {
    changeDate(val) {
      this.form.approvalDate = val;
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    saveForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          api.updateSocietyOrg(this.form).then(res => {
            if (res.data) {
              this.$message({
                type: "success",
                message: "更新成功!"
              });
            } else {
              this.$message({
                type: "error",
                message: "更新失败!"
              });
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    }
  },
  mounted() {
    let queryId = this.$route.query.id;
    api.getOrgCode().then(res => {
      (this.GridID = res.data.netGrid),
        (this.SocietyOrgType = res.data.codeSocietyOrgTypeValue),
        (this.personType = res.data.codeDocumentType),
        (this.AttentionType = res.data.codeAttentionTypeValue);
    });
    api.getToUpdateSocietyOrgInfo(queryId).then(res => {
      this.form = res.data;
    });
  }
};
</script>


<style scoped>

</style>
